using CustomerContactSystem.Core.Infrastructure.Domain;

namespace CustomerContactSystem.Core.Model {
    public class EnquiryFirstReferral : Entity {
        public virtual User FirstReferredTo { get; set; }
        public virtual Department FirstReferredToDepartment { get; set; }
        public virtual UserGroup FirstReferredToGroup { get; set; }

        protected override void Validate() {
            if (FirstReferredTo == null || FirstReferredTo.Id == 0) {
                AddBrokenRule(new BusinessRule("CurrentlyReferredTo", "Currently referred to is required!"));
            }

            if (FirstReferredToDepartment == null || FirstReferredToDepartment.Id == 0) {
                AddBrokenRule(new BusinessRule("CurrentlyReferredToDepartment", "Department is required!"));
            }

            if (FirstReferredToGroup == null || FirstReferredToGroup.Id == 0) {
                AddBrokenRule(new BusinessRule("CurrentlyReferredToGroup", "Group is required!"));
            }
        }
    }
}